<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
	<meta charset="utf-8">
	<meta name="viewport" content="width=device-width, initial-scale=1.0">
	<title>HR医院 - 部门列表</title>
	<meta name="keywords" content="">
	<meta name="description" content="">

	<link rel="shortcut icon" th:href="@{favicon.ico}">
	<link th:href="@{/css/bootstrap.min.css}" rel="stylesheet">
	<link th:href="@{/css/font-awesome.css}" rel="stylesheet">

	<!-- Data Tables -->
	<link th:href="@{/css/plugins/dataTables/dataTables.bootstrap.css}"
		  rel="stylesheet">
	<link th:href="@{/css/animate.css}" rel="stylesheet">
	<link th:href="@{/css/style.css}" rel="stylesheet">

</head>
<body class="gray-bg">
	<div class="wrapper wrapper-content animated fadeInRight">
		<div class="row">
			<div class="col-sm-12">
				<div class="ibox float-e-margins">
					<div class="ibox-title">
						<h5>新闻列表</h5>
					</div>
					<div class="ibox-content">
						<div>
							<a href="/news/addOneNews" class="btn btn-success">添加新闻</a>
							<form method="get" th:action="@{/news/selectAllNews}"  id="searchform">
								<div class="col-sm-2">
									<input style="width:100%"  type="text" placeholder="新闻标题" class="form-control" name="newsTitle" th:value="${newsTitle}"/>
								</div>
								<div class="col-sm-2">
									<input style="width:100%" type="text" placeholder="新闻作者" class="form-control"  name="newsAuthor" th:value="${newsAuthor}">
								</div>
								<div class="col-sm-2">
									<select name="newsTypeId" class="form-control" >
										<option th:value="0">请选择新闻类别</option>
										<option th:each="newsType:${newsTypes}" th:value="${newsType.newsTypeId}"
												th:text="${newsType.newsTypeNames}"
												th:selected="${newsType.newsTypeId==newsTypeId}">
										</option>
									</select>
								</div>
								<div class="col-sm-2">
									<span class="input-group-btn">
										<input style="width:100%" type="submit" value="搜索" class="btn btn-default ">
									</span>
								</div>
							</form>

						</div>


						<table class="table table-striped table-bordered table-hover dataTables-example">
							<thead>
								<tr class="text-center">
									<td>标号</td>
									<td>新闻类型</td>
									<td>新闻标题</td>
									<td>新闻作者</td>
									<td>新闻时间</td>
									<td>点击量</td>
									<td>管理</td>
								</tr>
							</thead>
							<tbody>
							<!--以下代码需修改 -->

								<tr class="gradeA text-center"  th:each="news:${pageInfo.list}">
									<td th:text="${newsStat.index}">标号</td>
									<td th:text="${news.newsType.newsTypeNames}">新闻类型</td>
									<td th:text="${news.newsTitle}">新闻标题</td>
									<td th:text="${news.newsAuthor}">新闻作者</td>
									<td th:if="${#dates.format(news.newsDate,'yyyy-MM-dd')}!=null">
										<span>[[${#dates.format(news.newsDate,'yyyy-MM-dd')}]]</span>
									</td>
									<td th:unless="${#dates.format(news.newsDate,'yyyy-MM-dd')}!=null">
										<span>无</span>
									</td>
									<td th:text="${news.newsClick}">点击量</td>
									<td>
										<a  class="btn btn-primary btn-xs" th:href="@{'/news/updateNews?newsId='+${news.newsId}}">修改</a>
										<a class="btn btn-danger btn-xs ddel" th:href="@{${news.newsId}}">删除</a>
									</td>

								</tr>
							<!--以上代码需修改 -->
							</tbody>
						</table>
					</div>
				</div>
				<!--显示分页信息-->
				<div class="modal-footer no-margin-top">
					<div class="col-md-6">
						当前第 [[${pageInfo.pageNum}]]页,共 [[${pageInfo.pages}]] 页.一共 [[${pageInfo.total}]] 条记录
					</div>

					<ul class="pagination pull-right no-margin">
						<li th:if="${pageInfo.hasPreviousPage}">
							<a th:href="'/news/selectAllNews?pageNum=1'">首页</a>
						</li>

						<li class="prev" th:if="${pageInfo.hasPreviousPage}">
							<a th:href="'/news/selectAllNews?pageNum='+${pageInfo.prePage}">
								<<
							</a>
						</li>
						<!--遍历条数-->
						<li th:each="nav:${pageInfo.navigatepageNums}">
							<a th:href="'/news/selectAllNews?pageNum='+${nav}" th:text="${nav}" th:if="${nav != pageInfo.pageNum}"></a>
							<span style="font-weight: bold;background: #6faed9;" th:if="${nav == pageInfo.pageNum}" th:text="${nav}" ></span>
						</li>

						<li class="next" th:if="${pageInfo.hasNextPage}">
							<a th:href="'/news/selectAllNews?pageNum='+${pageInfo.nextPage}">
								>>
							</a>
						</li>

						<li>
							<a th:href="'/news/selectAllUsers?pageNum='+${pageInfo.pages}">尾页</a>
						</li>
					</ul>
				</div>

			</div>
		</div>
	</div>

	<!--表单中没有编写提交方式，默认是get,如果使用的是Rest方式，那么必须加method="post" -->
	<form th:action="@{/news/deleteOneNews}">
		<input type="hidden" name="newsId"/>
	</form>


	<!-- 全局js -->
	<script th:src="@{/js/jquery.min.js}"></script>
	<script th:src="@{/js/bootstrap.min.js}"></script>
	<script th:src="@{/js/plugins/jeditable/jquery.jeditable.js}"></script>

	<!-- Data Tables -->
	<script th:src="@{/js/plugins/dataTables/jquery.dataTables.js}"></script>
	<script th:src="@{/js/plugins/dataTables/dataTables.bootstrap.js}"></script>

	<!-- 自定义js -->
	<script th:src="@{/js/content.js}"></script>

	<script type="text/javascript">
		$(function () {
			$(".ddel").click(function () {
				var flag=confirm("确认要删除吗?");
				if(flag){
					var href=$(this).attr("href");//获取超链接的href属性值
					$("[name=newsId]").val(href);//给表单中的隐藏域赋值
					$("form").attr("action","/news/deleteOneNews");//当前的操作这一步可以不写，当提交到不同地址时一定要写
					$("form").submit();//手动提交表单
				}
				return false;
			});
		});
		// function selectRole() {
		// 	var userBranchId = $("#userBranch").val();
		// 	$.ajax({
		// 		type:"GET",
		// 		url:"/user/selectUsersByBranch?userBranchId=" + userBranchId,
		// 		async:true,
		// 		success:function (data) {
		// 			var rList = data;
		// 			var rSelect = "<option>请选择第几党支部</option>";
		// 			for(var j = 0; j < rList.length; j++){
		// 				rSelect += ("<option th:value='${rList[j].userBranchId}' th:text='${rList[j].userBranchName}' ></option>");
		// 			}
		// 			$("#selectRole").empty();
		// 			$("#selectRole").append(rSelect);
		// 		}
		// 	})
		// }
	</script>





</body>
</html>